package cn.schoolwow.util.module.check.instance.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.List;

public class CheckInstanceInValueListFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        Object value = flowContext.getData("value");
        List allowValueList = (List) flowContext.checkData("allowValueList");
        String message = (String) flowContext.checkData("message");

        if(!allowValueList.contains(value)){
            throw new IllegalArgumentException(message+"的值不合法!当前值:["+value+"],允许值列表:"+allowValueList);
        }
    }

    @Override
    public String name() {
        return "实例-检查非空字段";
    }
}